<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $this->systemName;?></title>
<link rel="stylesheet" href="<?php echo $this->baseUrl;?>/files/admin/css/main.css" />
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/jquery.js"></script>
<link rel="stylesheet" href="<?php echo $this->baseUrl;?>/files/admin/js/formValidator.jquery/style.css" />
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/formValidator.jquery/cn.js"></script>

<!--colorbox-->
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/colorbox.jquery/jquery.colorbox.js"></script>
<link href="<?php echo $this->baseUrl;?>/files/admin/js/colorbox.jquery/colorbox2.css" rel="stylesheet" type="text/css"/>
</head>

<body>
	<div id="main">
		<div id="navigation">当前位置：<a href="<?php echo $this->projectUrl(array('action'=>'index'));?>">分支协议列表</a> &gt; <a href="<?php echo $this->projectUrl(array('action'=>'child-event','childVersion'=>$this->vars['childVersion']));?>">[<?php echo $this->vars['childVersion'];?>]事件列表</a> &gt;<a href="<?php echo $this->projectUrl(array('action'=>'child-field-enum','childVersion'=>$this->vars['childVersion'],'eventId'=>$this->vars['eventId'],'fieldSort'=>$this->vars['fieldSort']));?>">[<?php echo $this->vars['eventId'];?>]枚举列表</a>&gt;<span id="focus">编辑枚举值</span></div>
		<div id="body">
			<div id="edit">
				<form id="editForm" name="editForm" method="post" action="">
					<table class="table">
						<tr>
							<td colspan="2">*为必填项</td>
						</tr>
						<tr>
							<td width="20%">分支协议版本号：</td>
							<td>
								<?php echo $this->row['childVersion'];?>
								<input name="childVersion" type="hidden"id="childVersion" value="<?php echo $this->row['childVersion'];?>" />
							</td>
						</tr>
						<tr>
							<td width="20%">事件Id：</td>
							<td>
								<?php echo $this->row['eventId'];?>
								<input name="eventId" type="hidden" id="eventId" value="<?php echo $this->row['eventId'];?>"/>
							</td>
						</tr>
						<tr>
							<td width="20%">字段序号：</td>
							<td>
								<?php echo $this->row['fieldSort'];?>
								<input name="fieldSort" type="hidden" id="fieldSort" value="<?php echo $this->row['fieldSort'];?>"/>
							</td>
						</tr>
						<?php if ($this->row['fieldType']=='N'){?>
						<tr>
							<td width="20%">枚举键：</td>
							<td>
								<input name="enum" type="text" class="validate[callback[checkEnum,1]] input" id="enum" value="<?php echo $this->row['enum'];?>" size="30" style="width:300px;" /> * 
								<?php if (in_array($this->fieldType,array('E','N'))){ echo '[0-127]';}?>
								<?php if (in_array($this->fieldType,array('F','G'))){ echo '[0-32767]';}?>
							</td>
						</tr>
						<tr>
							<td width="20%">枚举值：</td>
							<td>
								<input name="enumValue" type="text" class="validate[required] input" id="enumValue" value="<?php echo $this->row['enumValue'];?>" size="30" style="width:300px;" /> * 
							</td>
						</tr>
						<?php }else{?>
						<tr>
							<td width="20%">枚举键：</td>
							<td>
							    <?php echo $this->row['enum'];?>
								<input name="enum" type="hidden" id="enum" value="<?php echo $this->row['enum'];?>" />
							</td>
						</tr>
						<tr>
							<td width="20%">枚举值：</td>
							<td>
							    <?php echo $this->row['enumValue'];?>
								<input name="enumValue" type="hidden" id="enumValue" value="<?php echo $this->row['enumValue'];?>"/>
							</td>
						</tr>
						<?php }?>
						<tr>
							<td width="20%">枚举设定人：</td>
							<td><?php echo $this->row['enumAuthor'];?></td>
						</tr>
						<tr>
							<td width="20%">备注：</td>
							<td><textarea name="remark" cols="30" rows="5" class="input" id="remark" style="width:300px;"><?php echo $this->row['remark'];?></textarea></td>
						</tr>
						<tr>
							<td width="20%">&nbsp;</td>
							<td><input type="submit" name="button" id="button" value="提交" class="button"/></td>
						</tr>
					</table>
				</form>
			</div>
		</div>
	</div>

<script language="javascript">
function checkEnum(account)
{
    var url = '<?php echo $this->projectUrl(array('action'=>'get-event-field-enum-is-exists-by-json','id'=>$this->row['id'],'childVersion'=>$this->row['childVersion'],'eventId'=>$this->row['eventId'],'fieldSort'=>$this->row['fieldSort'], 'account'=>'{account}'), NULL, false);?>'+'?rand/' + Math.random();
	url = url.replace('{account}', account);
	checkResult = {'isRight':true, 'message':''};
	
	if ($.trim($("#enum").val()) == '') {
		return checkResult = {'isRight':false, 'message':'枚举键。'};
	}
	if (account != '') {
		$.ajax({
			type: "GET",
			url: url,
			dataType: "json",
			async: false,
			success: function(data){
				if (data == 1) {
					checkResult = {'isRight':false, 'message':'* 事件[<?php echo $this->vars['eventId'];?>]字段序号[<?php echo $this->vars['fieldSort'];?>]的枚举键已存在，请换一个。'};
				}
			} 
		}); 
	}
	return checkResult;
}

$("#editForm").submit(function(){
	return true;
});
</script>
</body>
</html>